#!/usr/bin/env python3
import os
import sys
import json

result = json.loads(open("deletion.json").read())
if result["result"] == "success":
	print("[-] \""+str(sys.argv[1])+"\" deleted from Neocities.")
	os.system("touch delresult.ok")
elif result["result"] == "error" and result["message"].count("was not found on your site, canceled deleting")>0:
	print("[!] \""+str(sys.argv[1])+"\" already deleted or file doesn't exist.")
	os.system("touch delresult.err")
elif result["result"] == "error":
	print("[!] \""+str(sys.argv[1])+"\" deletion failed. Response: \""+result["message"]+"\"")
	os.system("touch delresult.err")
else:
	print("[!] File deleted?... (parsing/response error)")

os.system("rm -f deletion.json")
